<template>
  <div>
    <!-- Form -->

    <span @click="person" class="edit">人员名单</span>
    <el-dialog title="管理员角色 — 人员名单" :visible.sync="dialogFormVisible" width="780px" @close="close">
      <!-- 用户名称 -->
      <div class="left">
        <!-- 角色 -->
        <span>用户名称：</span>
        <el-input v-model="input1" class="first" placeholder="请输入用户名称"></el-input>
        <el-button type="primary" class="search" @click="search">查询</el-button>
        <el-button class="reset" @click="reset">重置</el-button>
      </div>
      <!-- 表格 -->
      <el-table
        ref="singleTable"
        :data="tableData"
        style="width: 720px"
        class="table"
        border
        stripe
      >
        <el-table-column type="index" label="序号" width="52"></el-table-column>
        <el-table-column property="loginName" label="登录名" width="182"></el-table-column>
        <el-table-column property="realName" label="用户名称" width="182"></el-table-column>
        <el-table-column property="orgPath" label="所属部门及岗位" width="303px"></el-table-column>
      </el-table>
      <!-- 分页 -->
      <!-- 分页 -->
      <div class="fenye">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="params.pageNum"
          background
          :page-sizes="[2, 5,10]"
          :page-size="params.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>

      <!--结束-->
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button type="primary" @click="sure">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import Upload from "@/components/Upload/Upload.vue";
export default {
  props: ["id"],
  components: {
    Upload,
  },
  data() {
    return {
      params: {
        pageNum: 1,
        id: "",
        pageSize: 10,
        realName: "",
      },
      dialogFormVisible: false,
      // 请输入名称
      input1: "",
      // 列表
      tableData: [],
      // 总条数
      total: 0,
    };
  },
  methods: {
    cancel() {
      (this.input1 = ""), (this.dialogFormVisible = false);
    },
    sure() {
      (this.input1 = ""), (this.dialogFormVisible = false);
    },
    close() {
      (this.input1 = ""), (this.dialogFormVisible = false);
    },
    // 获取人员名单
    person() {
      this.dialogFormVisible = true;
      this.Api.personRole({
        pageNum: 1,
        id: this.id,
        pageSize: 10,
        realName: "",
      }).then((res) => {
        this.tableData = res.data.records;
        this.total = res.data.total;
      });
    },
    search() {
      console.log(this.input1);
      this.Api.personRoleSearch({
        pageNum: 1,
        pageSize: 10,
        id: this.id,
        realName: this.input1,
      }).then((res) => {
        this.tableData = res.data.records;

        this.total = res.data.total;
      });
    },
    // 重置
    reset() {
      (this.input1 = ""), this.person();
    },
    // 分页
    //数据条数发生变化
    handleSizeChange(newSize) {
      this.params.pageSize = newSize;
      this.person();
    },
    //翻页触发
    handleCurrentChange(currPage) {
      this.params.pageNum = currPage;
      this.person();
    },
  },
};
</script>
<style lang="less" scoped>
/deep/.el-button--NewlyBuild {
  width: 80px;
  height: 36px;
  background: rgba(61, 127, 255, 1);
  border-radius: 3px;
  padding: 0;
  color: white;
  margin-right: 10px !important;
}
/deep/.el-dialog__wrapper {
  z-index: 9999 !important;
  .el-dialog {
    .el-dialog__header {
      background: rgba(230, 233, 237, 1);
      border-radius: 8px 8px 0px 0px;
      border: 1px solid rgba(230, 233, 237, 1);
      padding: 11px 20px 11px 24px;
      .el-dialog__title {
        font-size: 18px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: rgba(51, 51, 51, 1);
        line-height: 24px;
        padding-right: 540px;
      }
      .el-dialog__headerbtn {
        top: 15px;
      }
    }
    .el-dialog__body {
      padding: 30px 30px 0 30px;
    }
  }
}
/deep/.el-textarea__inner {
  width: 260px;
  height: 100px;
}
/deep/.el-textarea .el-input__count {
  bottom: 3px;
  right: 98px;
}
.edit {
  display: block;
  color: #1677ff;
  font-size: 14px;
  border-left: none;
  width: 76px;
  height: 14px;
  text-align: center;
  line-height: 14px;
  border: none;
}
.left {
  display: flex;
  margin-top: 19px;
  align-items: center;
}
.el-button {
  width: 52px;
  height: 36px;
  padding: 0;
}
.search {
  margin-left: 10px;
}
.table {
  margin-top: 20px;
}
.el-button + .el-button {
  margin-left: 10px;
  margin-right: 10px;
}
.fenye {
  display: flex;
  justify-content: flex-end;
  margin-top: -20px;
  margin-bottom: 10px;
}
</style>